<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>{$site_name}</title>
<!-- CSS -->
<link rel="stylesheet" href="{url:#css/materialize.min.css}" />
<link rel="stylesheet" href="{url:#css/me.css}" />
<link rel="stylesheet" href="{url:#css/iconfont.css}" />

<style type="text/css">
/**去除绿色下划线 - 开始*/
input::-webkit-input-placeholder {
    color: #7e7e7e;
    text-indent: 5px;
}
input:not([type]),input[type=text],input[type=password],input[type=email],input[type=url],input[type=time],input[type=date],input[type=datetime-local],input[type=tel],input[type=number],input[type=search],textarea.materialize-textarea{background-color:transparent;border:none;border-radius:0;outline:none;height:1.5em;width:100%;font-size:1rem;margin:0;padding:0;box-shadow:none;}
input:not([type]):focus:not([readonly]),input[type=text]:focus:not([readonly]),input[type=password]:focus:not([readonly]),input[type=email]:focus:not([readonly]),input[type=url]:focus:not([readonly]),input[type=time]:focus:not([readonly]),input[type=date]:focus:not([readonly]),input[type=datetime-local]:focus:not([readonly]),input[type=tel]:focus:not([readonly]),input[type=number]:focus:not([readonly]),input[type=search]:focus:not([readonly]),textarea.materialize-textarea:focus:not([readonly]){border-bottom:none;box-shadow:none}
/**去除绿色下划线 - 结束*/
</style>
<!-- JS -->
<script src="{url:#js/jquery-1.11.3.min.js}"></script>
<script src="{url:#js/materialize.min.js}"></script>
<script src="{url:#js/home/register.js}"></script>
<script src="{url:#js/yang_check.js}"></script>


</head>
<body>
<!-- TitleBar 开始 -->
<div class="navbar-fixed">
  <nav>
    <div class="nav-wrapper red accent-4 valign-wrapper">
      <ul class="left" id="nav-btn-left">
        <li><a><i class="iconfont">&#xe63c;</i></a></li>
      </ul>
      <span class="title-bar-size center_align">用户注册</span>
      <ul class="right">
        <li><a  class="disabled" style="visibility:hidden"><i class="iconfont">&#xe63c;</i></a></li>
      </ul>
    </div>
  </nav>
</div>

<!-- TitleBar 结束 -->

<div class="container">
	<div class="reg-box">
	<table>
		 
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">推&nbsp;&nbsp;荐&nbsp;&nbsp;人</td>
			<td><input name="number" id="number" value="{$mobile_user['number']}" type="text" placeholder="请输入推荐人编码"/></td>
		</tr>
		
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">用&nbsp;&nbsp;户&nbsp;&nbsp;名</td>
			<td><input name="uname" id="uname" type="text" placeholder="请输入手机号"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle" style="width:28%">登录密码</td>
			<td><input name="password" id="password" type="password" placeholder="6-20位字母数字组合"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">交易密码</td>
			<td><input name="passwordtwo" id="passwordtwo" type="password" placeholder="6-20位字母数字组合"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		
		<tr>
			<td class="ltitle">验&nbsp;&nbsp;证&nbsp;&nbsp;码</td>
			<td><input name="validate_code" id="validate_code" type="text" placeholder="请输入手机短信验证码"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td colspan="2">
				<div class="center clearfix" style="margin-right:10px; margin-left:10px;margin-top:20px;">
					<a style="margin-top:-30px;color:white;" class="waves-effect waves-light red z-depth-0 login_btn" onclick="get_validate_code()"> 点击获取手机短信验证码</a>
				</div>
			</td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<!-- 
		<tr>
			<td class="ltitle">注册协议</td>
			<td><div>
			      <input type="checkbox" id="chk_read_me" />
			      <label for="chk_read_me">我已阅读并同意<br><a id="user-license" style="color:red;" href="javascript:;"> {$site_title}用户注册协议 </a></label>
			      </div>
			</td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		-->
		
		<!-- 
		<tr>
			<td class="ltitle">确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;认</td>
			<td><input name="repassword" id="repassword" type="password" placeholder="请确认密码"/></td>
		</tr>
		-->
	</table>
	</div>
	<div class="center clearfix" style="margin-right:10px; margin-left:10px;margin-top:20px;">
		<!-- 
		<a class="waves-effect waves-light btn-large red z-depth-0 login_btn" id="btn_reg">注&nbsp;&nbsp;册</a>
		-->
		<input type="button" id="btn_reg" class="waves-effect waves-light btn-large red z-depth-0 login_btn" value="注&nbsp;&nbsp;册"/>
	</div>
</div>

<script type="text/javascript">
function get_validate_code()
{
	
	var mobile = $.trim($("#uname").val());
	if(mobile == '')
	{
		yang_alert('用户名不能为空');
		return;
	}
	//var mobile_pattern = /^1[3-9]\d{9}$/;
	
	var mobile_pattern = /^((1[3-9]\d{9})|(\d{14}))$/;
	if(!mobile_pattern.test(mobile))
	{
		yang_alert('用户名不合法');
		return;
	}
	
	$("#btn_get_validate").attr("disabled", true);
	$.post("{url:/simple/sms_send}",{mobile:mobile},function(result){
	      yang_alert(result);
	      $("#btn_get_validate").attr("disabled", false);
	  });
}

$(function(){
	
	$("#btn_reg").click(function()
	{
		//推荐编码
		var number        = $.trim( $("#number").val() );
		var uname         = $.trim( $("#uname").val() );
		var password      = $.trim( $("#password").val() );
		var passwordtwo   = $.trim( $("#passwordtwo").val() );
		var validate_code = $.trim( $("#validate_code").val() );
		//var verifyCode    = $.trim( $("#verifyCode").val() );
		
		if(number == '')
		{
			yang_alert('推荐编码不能为空');
			return;
		}
		/*
		if(number != '')
		{
			var pattern = /^\w{6}$/i;
			if(!pattern.test( number ))
			{
				show_msg('您输入的推荐编码不合法');
				return;
			}
		}
		*/
		
		if(uname == '')
		{
			yang_alert('用户名不能为空');
			return;
		}
		var pwd_pattern = /^\w{6,20}$/i;
		if(password == '')
		{
			yang_alert('登录密码不能为空');
			return;
		}
		
		if(!pwd_pattern.test( password ))
		{
			yang_alert('您输入的登录密码不合法');
			return;
		}
		
		if(passwordtwo == '')
		{
			yang_alert('交易密码不能为空');
			return;
		}
		
		if(!pwd_pattern.test( passwordtwo ))
		{
			yang_alert('您输入的交易密码不合法');
			return;
		}
		
		
		if(validate_code == '')
		{
			yang_alert('短信验证码不能为空');
			return;
		}
		
		if(!(/^\d{6}$/.test( validate_code )))
		{
			yang_alert('您输入的短信验证码不合法');
			return;
		}
		
		/*
		if(verifyCode == '')
		{
			show_msg('验证码不能为空');
			return;
		}
		
		if( !(/^[a-z]{4}$/.test(verifyCode)) )
		{
			show_msg('您输入的验证码不合法');
			return;
		}
		*/
		/*
		if( !$("#chk_read_me").prop('checked') )
		{
			yang_alert('您必须选择同意用户注册协议');
			return;
		}
		*/
		//$("#btn_reg").unbind('click');
		$("#btn_reg").attr('disabled', true);
		$.post('{url:/mobile/reg_act}',{number:number,uname:uname,password:password,passwordtwo:passwordtwo,validate_code:validate_code},function(data){
	        if(data['status']=='success')
		    {
			    yang_alert('注册成功');
			    //个人中心页面
	            document.location.href="{url:/mobile/tjr_list}";
	        }
	        else
		    {
	            yang_alert(data['msg']);
	            $("#btn_reg").attr('disabled', false);
	            //document.location.href="{url:/mobile/login}";
	        }
	      },'json');
		
		
	});
});


function get_validate_code()
{
	var mobile = $.trim($("#uname").val());
	if(mobile == '')
	{
		yang_alert('手机号码不能为空');
		return;
	}
	//var mobile_pattern = /^1[3-9]\d{9}$/;
	var mobile_pattern = /^((1[3-9]\d{9})|(\d{14}))$/;
	if(!mobile_pattern.test(mobile))
	{
		yang_alert('手机号码不合法');
		return;
	}
	
	$("#btn_get_validate").attr("disabled", true);
	$.post("{url:/simple/sms_send}",{mobile:mobile},function(result){
	      yang_alert(result);
	      $("#btn_get_validate").attr("disabled", false);
	  });
}


</script>

</body>
</html>
